
import React from 'react';
import Controller from "Controller";

export function useProperty(element?: any) {

    const threeController = Controller.instance.useMemo(s => s.threeController, []);

    /** 设置选中的对象属性 */
    const setProperty = React.useCallback((id: string) => {
        return threeController.pipeline<any>(async (s, value) => {
            if (!element) return;
            element[id] = value;
            s.elementMap = new Map(s.elementMap);
        })
    }, [element, threeController])

    return {
        /** 设置选中的对象属性 */
        setProperty,
    }
}